//
//  KSKARoomCell.m
//  DashboardHD
//
//  Created by 楊亜玲 on 17/4/7.
//  Copyright © 2017年 Totyu. All rights reserved.
//

#define NameFont [UIFont systemFontOfSize:14]
#define TextFont [UIFont systemFontOfSize:15]
#import "KSKARoomCell.h"
#import "UIImageView+WebCache.h"

@interface KSKARoomCell ()

@end

@implementation KSKARoomCell


-(void)setRoom:(KSKAMainResult *)room{
    _room = room;
    
    // 设置内容
    self.roomLabel.text = room.roomname;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:room.picpath]];
    self.nameLabel.text = room.username0;
    //[self.nameLabel adjustsFontSizeToFitWidth];
    //CGSize test = [self sizeWithText:room.username0 font:NameFont maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
    //KSKLog(@"%@",test);
    self.ageLabel.text = room.userold;
    self.sexLabel.text = room.usersex;
    self.temperatureLabel.text = [NSString stringWithFormat:@"%@%@",room.tvalue.description,room.tunit];
    self.lumunanceLabel.text = room.bd;
    
    
    // 设置颜色
    self.bgview.backgroundColor = KSKAMainColor;
    self.bgImageView.image = [UIImage resizedImageWithName:@"common_card_background_os7"];
    //self.bgImageView.highlightedImage = [UIImage resizedImageWithName:@"common_card_background_highlighted_os7"];
}


/**
 *  计算文字尺寸
 *
 *  @param text    需要计算尺寸的文字
 *  @param font    文字的字体
 *  @param maxSize 文字的最大尺寸
 */
-(CGSize)sizeWithText:(NSString*)text font:(UIFont *)font maxSize:(CGSize)maxSize{
    NSDictionary *attrs = @{NSFontAttributeName : font};//文字字体大小
    return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}

@end

